<?php

//headers
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers, Content-Type, Access-Control-Allow-Methods, Authorization, X-Requested-With');

//index db
include_once('../../index.php');

//receive properties
$data = json_decode(file_get_contents("php://input"));

//index properties
$post = new Post($db);
$post->rol = $data->rol;
$post->name = $data->name;
$post->password = $data->password;

//create user
if ($post->create()) {
  echo json_encode(
    array('message' => 'Post created.')
  );
}
else {
  echo json_encode(
    array('message' => 'Post not created.')
  );
}

?>